package cn.zhaozhiqi.controller.app;

import cn.zhaozhiqi.constants.Constants;
import cn.zhaozhiqi.pojo.domain.PayOrder;
import cn.zhaozhiqi.result.JSONResult;
import cn.zhaozhiqi.service.IPayOrderService;
import cn.zhaozhiqi.service.IPayService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/app/pay")
public class AppPayController {

    @Autowired
    public IPayOrderService payOrderService;
    @Autowired
    public IPayService payService;


    @Operation( summary= "调用支付宝支付",description = "调用支付宝支付接口")
    @Parameter(name = "orderNo",description = "订单号",required = true)
    @PostMapping("/alipay/{orderNo}")
    public JSONResult alipay(@PathVariable String orderNo){
        return JSONResult.success(payService.alipay(orderNo,Constants.PayType.ALIPAY));
    }


    @Operation( summary= "绑定cid和别名（customerId）的关系",description = "绑定cid和别名（customerId）的关系接口")
    @Parameter(name = "cid",description = "调用个推返回的cid",required = true)
    @PostMapping("/bindalias/{cid}")
    public JSONResult bindalias(@PathVariable String cid){
        return JSONResult.success(payOrderService.bindalias(cid));
    }
}
